using UnityEngine;
// [Assembly-CSharp.dll].SpiningWheel
public class SpiningWheel : MonoBehaviour
{
    
    #region SpiningWheel.<>c__DisplayClass25_0
    // [Assembly-CSharp.dll].SpiningWheel.<>c__DisplayClass25_0
    private sealed class __c__DisplayClass25_0
    {
        // Fields
        public UnityEngine.Transform obj;
        public SpiningWheel __4__this;
        public UnityEngine.Transform objparrent;
        public UnityEngine.Vector3 objPosition;
        public DG.Tweening.TweenCallback __9__3;
        public DG.Tweening.TweenCallback __9__2;
        public DG.Tweening.TweenCallback __9__1;
        
        // Methods
        public __c__DisplayClass25_0()
        {
        
        }
        internal void <SelectedGiftAnim>b__0()
        {
            DG.Tweening.TweenCallback val_6;
            DG.Tweening.Core.TweenerCore<UnityEngine.Quaternion, UnityEngine.Vector3, DG.Tweening.Plugins.Options.QuaternionOptions> val_1 = DG.Tweening.ShortcutExtensions.DORotate(target:  this.obj, endValue:  new UnityEngine.Vector3() {x = mem[536895737], y = mem[536895737] + 4, z = mem[536895737] + 8}, duration:  1f, mode:  0);
            val_6 = this.__9__1;
            if(val_6 == null)
            {
                    DG.Tweening.TweenCallback val_4 = 536894577;
                val_6 = val_4;
                val_4 = new DG.Tweening.TweenCallback(object:  this, method:  1610677721);
                this.__9__1 = val_6;
            }
            
            Unknown val_5 = DG.Tweening.TweenSettingsExtensions.OnComplete<System.Object>(t:  DG.Tweening.TweenSettingsExtensions.SetEase<System.Object>(t:  DG.Tweening.ShortcutExtensions.DOMove(target:  this.obj, endValue:  new UnityEngine.Vector3() {x = mem[536895737], y = mem[536895737] + 4, z = mem[536895737] + 8}, duration:  1f, snapping:  false), ease:  27), action:  val_6);
        }
        internal void <SelectedGiftAnim>b__1()
        {
            DG.Tweening.TweenCallback val_8;
            this.__4__this.wheelPin.transform.parent.gameObject.SetActive(value:  false);
            this.__4__this.spinWheelButton.SetActive(value:  false);
            float val_8 = mem[536895737] + 12;
            float val_9 = mem[536895737] + 12 + 4;
            float val_10 = mem[536895737] + 20;
            val_8 = val_8 + val_8;
            val_9 = val_9 + val_9;
            val_10 = val_10 + val_10;
            val_8 = this.__9__2;
            if(val_8 == null)
            {
                    DG.Tweening.TweenCallback val_6 = 536894577;
                val_8 = val_6;
                val_6 = new DG.Tweening.TweenCallback(object:  this, method:  1610677723);
                this.__9__2 = val_8;
            }
            
            Unknown val_7 = DG.Tweening.TweenSettingsExtensions.OnComplete<System.Object>(t:  DG.Tweening.TweenSettingsExtensions.SetEase<System.Object>(t:  DG.Tweening.ShortcutExtensions.DOScale(target:  this.obj, endValue:  new UnityEngine.Vector3() {x = val_8, y = val_9, z = val_10}, duration:  1f), ease:  1), action:  val_8);
        }
        internal void <SelectedGiftAnim>b__2()
        {
            DG.Tweening.TweenCallback val_4 = this.__9__3;
            if(val_4 == null)
            {
                    DG.Tweening.TweenCallback val_2 = 536894577;
                val_4 = val_2;
                val_2 = new DG.Tweening.TweenCallback(object:  this, method:  1610677725);
                this.__9__3 = val_4;
            }
            
            Unknown val_3 = DG.Tweening.TweenSettingsExtensions.OnComplete<System.Object>(t:  DG.Tweening.ShortcutExtensions.DOScale(target:  this.obj, endValue:  new UnityEngine.Vector3() {x = mem[536895737], y = mem[536895737] + 4, z = mem[536895737] + 8}, duration:  0.5f), action:  val_4);
        }
        internal void <SelectedGiftAnim>b__3()
        {
            float val_11 = mem[536895737];
            float val_12 = mem[536895737] + 4;
            float val_13 = mem[536895737] + 8;
            val_11 = val_11 * 0.01745329f;
            val_12 = val_12 * 0.01745329f;
            val_13 = val_13 * 0.01745329f;
            UnityEngine.Quaternion val_2 = UnityEngine.Quaternion.Internal_FromEulerRad(euler:  new UnityEngine.Vector3() {x = val_11, y = val_12, z = val_13});
            this.__4__this.rb.transform.rotation = new UnityEngine.Quaternion() {x = val_2.x, y = val_2.y, z = val_2.z, w = val_2.w};
            this.obj.parent = this.objparrent;
            this.obj.localPosition = new UnityEngine.Vector3() {x = this.objPosition, y = val_2.y, z = val_2.z};
            float val_14 = mem[536895737];
            float val_15 = mem[536895737] + 4;
            float val_16 = mem[536895737] + 8;
            val_14 = val_14 * 0.01745329f;
            val_15 = val_15 * 0.01745329f;
            val_16 = val_16 * 0.01745329f;
            UnityEngine.Quaternion val_3 = UnityEngine.Quaternion.Internal_FromEulerRad(euler:  new UnityEngine.Vector3() {x = val_14, y = val_15, z = val_16});
            this.obj.rotation = new UnityEngine.Quaternion() {x = val_3.x, y = val_3.y, z = val_3.z, w = val_3.w};
            this.obj.localScale = new UnityEngine.Vector3() {x = mem[536895737] + 12, y = mem[536895737] + 12 + 4, z = mem[536895737] + 20};
            mem[536882947].PlayEffect2(clip:  mem[536882947] + 144);
            mem[536882947].PlayEffect1(clip:  mem[536882947] + 152);
            var val_17 = 0;
            label_20:
            if(val_17 >= this.__4__this.fireWork.childCount)
            {
                goto label_16;
            }
            
            this.__4__this.fireWork.GetChild(index:  0).GetComponent<System.Object>().Play();
            val_17 = val_17 + 1;
            if(this.__4__this != null)
            {
                goto label_20;
            }
            
            label_16:
            this.__4__this.Invoke(methodName:  -1610608755, time:  5f);
            this.__4__this.Invoke(methodName:  -1610609943, time:  5.1f);
            if((System.String.op_Equality(a:  this.obj.name, b:  -1610599799)) != false)
            {
                    this.__4__this.animatedCoins.SetActive(value:  true);
                return;
            }
            
            if((System.String.op_Equality(a:  this.obj.name, b:  -1610596151)) != false)
            {
                    this.__4__this.Skin();
                return;
            }
            
            this.__4__this.Gift();
        }
    
    }
    
    #endregion
    
    // Fields
    public UnityEngine.Rigidbody2D rb;
    public UnityEngine.GameObject spinWheelButton;
    public UnityEngine.GameObject spinWheelParrent;
    public UnityEngine.GameObject animatedCoins;
    public UnityEngine.GameObject spinWheelADPanel;
    public UnityEngine.GameObject noThanksButton;
    public UnityEngine.GameObject itemSparkle;
    public bool spined;
    public WheelPin wheelPin;
    public UnityEngine.Sprite[] DogSprites;
    public System.Collections.Generic.List<int> lockedIndex;
    public UnityEngine.UI.Image imageUnLocked;
    private UnityEngine.AudioSource audioSource;
    public UnityEngine.Transform fireWork;
    private int[] force;
    
    // Methods
    private void OnEnable()
    {
        var val_13;
        var val_14;
        mem[536882947].PlayEffect2(clip:  mem[536882947] + 136);
        this.audioSource = this.GetComponent<System.Object>();
        this.spinWheelButton.SetActive(value:  true);
        this.noThanksButton.SetActive(value:  true);
        this.spinWheelParrent.SetActive(value:  true);
        this.imageUnLocked.gameObject.SetActive(value:  false);
        this.audioSource.volume = 0f;
        this.audioSource.Play();
        this.itemSparkle.SetActive(value:  false);
        this.spinWheelButton.GetComponent<System.Object>().enabled = false;
        this.Invoke(methodName:  -1610609941, time:  3f);
        this.CheckForLocked();
        val_13 = 536886631;
        if(mem[536886855] == 0)
        {
                val_13 = 536886631;
        }
        
        UnityEngine.GameObject val_6 = this.spinWheelButton.transform.GetChild(index:  0).gameObject;
        if(mem[536886815] >= 4)
        {
                val_6.SetActive(value:  false);
            Unknown val_7 = this.spinWheelButton.GetComponent<System.Object>();
            val_7 + 248.RemoveAllListeners();
            Unknown val_8 = this.spinWheelButton.GetComponent<System.Object>();
            UnityEngine.Events.UnityAction val_9 = 536895085;
            val_9 = new UnityEngine.Events.UnityAction(object:  this, method:  1610677711);
            val_8 + 248.AddListener(call:  val_9);
            val_14 = 536886631;
            if(mem[536886855] == 0)
        {
                val_14 = 536886631;
        }
        
            mem2[0] = 0;
            return;
        }
        
        val_6.SetActive(value:  true);
        Unknown val_10 = this.spinWheelButton.GetComponent<System.Object>();
        val_10 + 248.RemoveAllListeners();
        Unknown val_11 = this.spinWheelButton.GetComponent<System.Object>();
        UnityEngine.Events.UnityAction val_12 = 536895085;
        val_12 = new UnityEngine.Events.UnityAction(object:  this, method:  1610677713);
        val_11 + 248.AddListener(call:  val_12);
    }
    private void OnDisable()
    {
        mem2[0] = 0;
        mem2[0] = W9 + 1;
    }
    private void Start()
    {
    
    }
    private void CheckForLocked()
    {
        do
        {
            if(1 >= this.DogSprites.Length)
        {
                return;
        }
        
            string val_7 = -1610599175;
            if((UnityEngine.PlayerPrefs.GetInt(key:  val_7 + 1.ToString())) != 1)
        {
                var val_4 = W10 + 1;
            mem2[0] = val_4;
            if(val_4 < mem[2684368145])
        {
                val_7 = val_7 + (((W10 + 1)) << 2);
            mem2[0] = val_4 + 1;
            mem2[0] = 1;
        }
        
        }
        
            var val_6 = 1 + 1;
        }
        while(this.DogSprites != null);
        
        throw new NullReferenceException();
    }
    private void Update()
    {
        this.CheckAngulerVelocity();
    }
    private void CheckAngulerVelocity()
    {
        this.audioSource.volume = this.rb.angularVelocity;
        if(this.rb.angularVelocity > 0f)
        {
                this.spined = true;
        }
        else
        {
                if(this.spined == false)
        {
                return;
        }
        
        }
        
        if(this.rb.angularVelocity != 0f)
        {
                return;
        }
        
        this.spined = false;
        this.SelectedGiftAnim();
    }
    private void ActiveAnimator()
    {
        this.spinWheelButton.GetComponent<System.Object>().enabled = true;
    }
    public void SpinButton()
    {
        mem[536882947].LightImpect();
        mem[536882947] + 56.Play();
        this.spinWheelADPanel.SetActive(value:  true);
    }
    public void SpinOnClickYes()
    {
        mem[536882947].LightImpect();
        mem[536882947] + 56.Play();
        System.Action val_1 = 536881997;
        val_1 = new System.Action(object:  this, method:  1610677697);
        mem[536882295].ShowRewardedAd(_successCallBack:  val_1);
    }
    private void SpinTheWheel()
    {
        System.Action val_1 = 536881997;
        val_1 = new System.Action(object:  this, method:  1610677715);
        mem[536895333].AddJob(newJob:  val_1);
    }
    private void SelectedGiftAnim()
    {
        SpiningWheel.SpiningWheel___c__DisplayClass25_0 val_1 = 536900401;
        val_1 = new SpiningWheel.SpiningWheel___c__DisplayClass25_0();
        mem[536900425] = this;
        mem[536900417] = this.wheelPin.selectedObject.transform;
        UnityEngine.Vector3 val_3 = mem[536900417].localPosition;
        mem[536900441] = val_3.x;
        mem[536900445] = val_3.y;
        mem[536900449] = val_3.z;
        mem[536900433] = mem[536900417].parent;
        mem[536900417].parent = this.transform;
        UnityEngine.Vector3 val_6 = mem[536900417].position;
        DG.Tweening.TweenCallback val_10 = 536894577;
        val_10 = new DG.Tweening.TweenCallback(object:  val_1, method:  1610677719);
        Unknown val_11 = DG.Tweening.TweenSettingsExtensions.OnComplete<System.Object>(t:  DG.Tweening.TweenSettingsExtensions.SetEase<System.Object>(t:  DG.Tweening.ShortcutExtensions.DOMoveY(target:  mem[536900417], endValue:  val_6.y + 1f, duration:  1f, snapping:  false), ease:  27), action:  val_10);
    }
    private void Gift()
    {
        if((UnityEngine.Random.Range(minInclusive:  0, maxExclusive:  5)) != 0)
        {
                this.animatedCoins.SetActive(value:  true);
            return;
        }
        
        this.Skin();
    }
    private void Skin()
    {
        this.itemSparkle.SetActive(value:  true);
        Unknown val_2 = this.lockedIndex.Item[UnityEngine.Random.Range(minInclusive:  0, maxExclusive:  1)];
        UnityEngine.Debug.Log(message:  536888099);
        UnityEngine.PlayerPrefs.SetInt(key:  -1610599175(-1610599175) + val_2.ToString(), value:  1);
        if(val_2 < this.DogSprites.Length)
        {
                this.imageUnLocked.sprite = this.DogSprites[val_2];
            this.imageUnLocked.transform.localScale = new UnityEngine.Vector3() {x = mem[536895737], y = mem[536895737] + 4, z = mem[536895737] + 8};
            this.imageUnLocked.gameObject.SetActive(value:  true);
            UnityEngine.Camera.main.GetComponent<System.Object>().CheackIsUnLocked(str:  -1610599175);
            Unknown val_11 = DG.Tweening.TweenSettingsExtensions.SetEase<System.Object>(t:  DG.Tweening.ShortcutExtensions.DOScale(target:  this.imageUnLocked.transform, endValue:  new UnityEngine.Vector3() {x = mem[536895737] + 12, y = mem[536895737] + 12 + 4, z = mem[536895737] + 20}, duration:  1f), ease:  30);
            return;
        }
    
    }
    public void ClosePanel()
    {
        this.animatedCoins.SetActive(value:  false);
        mem[536882947] + 56.Play();
        mem[536882947].LightImpect();
        this.gameObject.SetActive(value:  false);
    }
    public void ActiveAgain()
    {
        this.gameObject.SetActive(value:  true);
    }
    public SpiningWheel()
    {
        this.force = 536881231;
    }
    private void <OnEnable>b__15_0()
    {
        this.SpinTheWheel();
    }
    private void <OnEnable>b__15_1()
    {
        this.SpinButton();
    }
    private void <SpinTheWheel>b__24_0()
    {
        int val_1 = UnityEngine.Random.Range(minInclusive:  0, maxExclusive:  this.force.Length);
        if(val_1 < this.force.Length)
        {
                this.rb.AddTorque(torque:  (float)this.force[val_1]);
            mem[536882947].LightImpect();
            this.spinWheelADPanel.SetActive(value:  false);
            mem[536882947] + 56.Play();
            this.spinWheelButton.SetActive(value:  false);
            this.noThanksButton.SetActive(value:  false);
            return;
        }
    
    }

}
